<HTML><HEAD><TITLE>local array(++Array)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Non-logical Variables, Arrays, Bags, Shelves and Stores</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>local array(++Array)</H1>
Creates the untyped non-logical array Array.
<DL>
<DT><EM>Array</EM></DT>
<DD>Ground compound term with integer arguments.
</DD>
</DL>
<H2>Description</H2>
   If Array is a compound term, a non-logical array (visible only in
   the caller module) of type prolog is created.  Its dimension is the
   arity of the term Array and the size of each dimension is specified
   by the corresponding argument of the term Array.  The elements of
   arrays of type prolog are initialised to free variables.
<P>
   The array indexes in the array range from 0 to the dimension minus one.
   For example myarray create with <CODE>local array(myarray(3,4,5))</CODE>
   contains 60 elements that may be accessed from myarray(0,0,0)
   to myarray(2,3,4).
<P>
   The contents of the array persists across failures.
   The value of the array elements can be changed with
   setval/2 and retrieved with getval/2.  Setting and retrieving terms
   from a non-logical arrays involves copying the term each time. 
   In particular, if the term contains variables, they lose their
   identity and are replaced with fresh ones.
<P>
   Notes:
<P>
   <CODE>local array(A)</CODE> is equivalent to <CODE>local array(A, prolog)</CODE>.

<H3>Modes and Determinism</H3><UL>
<LI>array(++) is det
</UL>
<H3>Exceptions</H3>
<DL>
<DT><EM>(4) instantiation fault </EM>
<DD>Array is not ground.
<DT><EM>(5) type error </EM>
<DD>Array is not a structure with integer arguments.
<DT><EM>(6) out of range </EM>
<DD>The ground structure Array has arguments that are integers not greater than 0.
<DT><EM>(24) number expected </EM>
<DD>The ground structure Array has arguments that are non-numbers.
<DT><EM>(42) redefining an existing array </EM>
<DD>An array with the same name and dimension as Array already exists.
</DL>
<H2>Examples</H2>
<PRE>
Success:
      local array(a(4)).
      local array(b(2,3)).
      local array(a(4)), array(a(4,1)).

Error:
      local array(X).                        (Error 4).
      local array(a(6.0)).                   (Error 5).
      local array(a(0)).                     (Error 6).
      local array(a(-2)).                    (Error 6).
      local array(a(4)), array(a(5)).        (Warning 42).
</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/storage/current_array-2.html">current_array / 2</A>, <A HREF="../../kernel/storage/array-2.html">array / 2</A>, <A HREF="../../kernel/storage/decval-1.html">decval / 1</A>, <A HREF="../../kernel/storage/incval-1.html">incval / 1</A>, <A HREF="../../kernel/storage/bag_create-1.html">bag_create / 1</A>, <A HREF="../../kernel/storage/shelf_create-2.html">shelf_create / 2</A>, <A HREF="../../kernel/storage/shelf_create-3.html">shelf_create / 3</A>, <A HREF="../../kernel/storage/getval-2.html">getval / 2</A>, <A HREF="../../kernel/storage/setval-2.html">setval / 2</A>
</BODY></HTML>
